#include "StdAfx.h"
#include "Ground.h"


CGround::CGround(void)
{
	m_eGrdType = CHASSIS_GROUND;
}

CGround::CGround(eGroundType eType)
{
	m_eGrdType = eType;
}

CGround::CGround( const CGround* pEntityObj )
	:CGroundUnit(pEntityObj)
{
	m_eGrdType = pEntityObj->GetGroundType();

	m_sGroundIndex = pEntityObj->GetGroundIndex();
	m_sWireIndex = pEntityObj->GetWireIndex();
	m_sSolderA = pEntityObj->GetSolderA();
	m_sSolderB = pEntityObj->GetSolderB();
	m_sWireLen = pEntityObj->GetWireLen();
	m_sNoteInfo = pEntityObj->GetNoteInfo();
}

CGround::~CGround(void)
{
}

void CGround::Serialize(CArchive & ar)
{
	if (ar.IsStoring())
	{
		ar << m_eGrdType;
		CObj::WriteString(ar,m_sGroundIndex);
		CObj::WriteString(ar,m_sWireIndex);
		CObj::WriteString(ar,m_sSolderA);
		CObj::WriteString(ar,m_sSolderB);
		CObj::WriteString(ar,m_sWireLen);
		CObj::WriteString(ar,m_sNoteInfo);
	}
	else
	{
		int nType(0);
		ar >> nType;
		m_eGrdType = (eGroundType)nType;
		if (CObj::m_lFileVersion >= 114)
		{
			CObj::ReadString(ar,m_sGroundIndex);
			CObj::ReadString(ar,m_sWireIndex);
			CObj::ReadString(ar,m_sSolderA);
			CObj::ReadString(ar,m_sSolderB);
			CObj::ReadString(ar,m_sWireLen);
			CObj::ReadString(ar,m_sNoteInfo);
		}
	}

	CGroundUnit::Serialize(ar);
}

eGroundType CGround::GetGroundType() const
{
	return m_eGrdType;
}

void CGround::SetGroundType(eGroundType type)
{
	m_eGrdType = type;
}

void CGround::Clear()
{
	 CGroundUnit::Clear( );
}

void CGround::CopyDisplayObj( long lSourceLayerId, long lDestLayerId )
{
	CGroundUnit::CopyDisplayObj( lSourceLayerId, lDestLayerId );
}

void CGround::DeleteDisplayObj( long lLayerId )
{
	CGroundUnit::DeleteDisplayObj( lLayerId );
}

CDisplayObj * CGround::CreateDisplayObj( long lLayerId )
{
	CGroundDisplayObj* pGndDis = new CGroundDisplayObj(this);
	pGndDis->SetLayerId(lLayerId);

	return pGndDis;
}

CObj * CGround::Clone() const
{
	return new CGround(this);
}

void CGround::Transform( const CMatrix transf )
{
	throw std::exception("The method or operation is not implemented.");
}

bool CGround::GetBox( double & dblLeft, double & dblBottom, double & dblRight, double & dblTop ) const
{
	throw std::exception("The method or operation is not implemented.");
}

eGroundUnitEntType CGround::GetGroundUnitType() const
{
	return GROUND_GROUND;
}
